#include "rEngine.h"

#include <assert.h>

rEngine::rEngine(void):
	pMainBuffer(),
	pStreams(),
	pTypes()
{
	
}


rEngine::~rEngine(void)
{
}

void rEngine::Render()
{
	pTypes[pMainBuffer.getId()]->Render(&pMainBuffer,pStreams[pMainBuffer.getStreamId()]);
}



void rEngine::OpenStream(std::iostream* stream)
{
	pStreams.push_back(stream);
	pMainBuffer.setStreamId(pStreams.size()-1);	 
}

int rEngine::RegisterType(IItemType* type)
{
	IItemType::IIType prev = type->getType();
	if( prev < 0 )
	{
		pTypes.push_back(type);
		type->setType(pTypes.size()-1);
		pMainBuffer.setId(pTypes.size()-1);	   //
		return pTypes.size()-1;	   		
	} else return prev;		 	
}